<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" id="username">
    <input type="text" id="password">
    <script>
        var username = document.getElementById("username");
        username.onkeydown = function(e){
            // console.log(e.target.value);//value属性就是输入框的数据
            console.log("按下了");
        }
        username.onkeyup = function(e){
            console.log(e.target.value);//value属性就是输入框的数据
        }
        //ctrl,alt,shift,Meta不能触发keypress事件，数字和字母是有值的，其他的无值
        username.onkeypress = function(){
            console.log("keypress");//value属性就是输入框的数据
        }

        var password = document.getElementById("password");
        password.onkeyup= function(e){
            //keyCode代表每个按键的唯一标识
            console.log(e.keyCode);
            if(e.keyCode === 13){
                console.log("开始搜索");
            }
        }
    </script>
</body>
</html>